/**
 * Copyright (C), 2015-2018, XXX有限公司
 * FileName: BaseControllerWarpper
 * Author:   zhouheng
 * Date:     2018/6/22 14:13
 * Description: 控制器查询结果包装类基类
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.hengby.hengcrud.modular.base.wrap;

import java.util.List;
import java.util.Map;

/**
 * 〈一句话功能简述〉<br> 
 * 〈控制器查询结果包装类基类〉
 *
 * @author zhouheng
 * @create 2018/6/22
 * @since 1.0.0
 */
public abstract class BaseControllerWarpper {
    public Object obj = null;

    public BaseControllerWarpper(Object obj) {
        this.obj = obj;
    }

    public Object wrap(){
        if (this.obj instanceof List){
            List<Map<String, Object>> list = (List<Map<String, Object>>) this.obj;
            for (Map<String, Object> map : list) {
                warpTheMap(map);
            }
            return list;
        }else if (this.obj instanceof Map){
            Map<String, Object> map = (Map<String, Object>) this.obj;
            warpTheMap(map);
            return map;
        }else {
            return this.obj;
        }
    }

    protected abstract void warpTheMap(Map<String, Object> map);
}